#ifndef BASEVIEW_H
#define BASEVIEW_H

#include <QtGui>
#include <QList>

#include "core/basemodel.h"
#include "core/basecontroller.h"
#include "gui/shinylist.h"
#include "gui/separatorwidget.h"

/*
  BaseView provides common functionality that is shared between all
  of the view classes of mensei-system. It sets up the common UI widgets
  and provides utilities that reduce code redundancy where possible,
  e.g. the detailsRequested signal.
 */
class BaseView : public QWidget
{
    Q_OBJECT
public:
    explicit BaseView(QWidget *parent = 0);
    BaseController *getController();
    void setController(BaseController *controller);

signals:
    // Handlers for displayed model details should be connected to this signal.
    void detailsRequested(BaseModel *model);

public slots:
    virtual void onDataUpdate(QList<BaseModel *> models);
    void onShinyListDoubleClicked(QModelIndex index);

protected:
    // Allow these methods to be overridden, so the UI can be modified with
    // minimal hassle.
    virtual QHBoxLayout *createFilterComponents();
    virtual QHBoxLayout *createBottomComponents();
    virtual void initViewComponents();
    virtual void initViewSignalsAndSlots();
    void hideReportsWidgets();

    QList<BaseModel *> models;

    // UI widgets
    QVBoxLayout *mainLayout;
    QLabel *topLabel;

    QHBoxLayout *filterLayout;
    QLineEdit *filterEdit;
    QComboBox *filterBox;
    SeparatorWidget *filterSeparator;
    QPushButton *reportsButton;

    ShinyList *slist;

    QHBoxLayout *buttonLayout;
    QPushButton *addButton;

private:
    BaseController *controller;
};

#endif // BASEVIEW_H
